using System.Collections.Generic;
using UnityEngine;

public class plane_smothfollow : MonoBehaviour
{
	public static plane_smothfollow instance;

	public HealthController PlayerHealth;

	public bool isdied;

	public Transform target;

	public Transform bodypoint;

	public Transform m_Transform;

	public Camera mainCam;

	public Camera nearCam;

	public CamMove cam_move;

	public float posDamping;

	public float rotationDamping;

	private Vector3 curpos;

	private Quaternion start_ro;

	private Quaternion end_to;

	public Transform plane_body;

	public Transform leftblank;

	public Transform rightblank;

	public Transform leftempennage;

	public Transform rightempennage;

	public float empennage_angle;

	private float empennage_curangle;

	public float flank_angle;

	private float flank_curangle_left;

	private float flank_curangle_right;

	public Transform left_fire;

	public Transform right_fire;

	public Transform left_missile;

	public Transform right_missile;

	public Transform left_jet;

	public Transform right_jet;

	public Transform youdaodan_point;

	public GameObject speedsmoke;

	public float machinespeed;

	public float guidemissilespeed;

	public bool machinegunFlag;

	public bool guidedmissileFlag;

	public bool singlemissileFlag;

	public bool accflag;

	public bool decflag;

	public float fightdistance;

	private bulletmove curbullet;

	private missilemove curmissile;

	public AIController curAI;

	public int bullet_hurtdamage;

	public int bullet_penetrationVal;

	public int missile_hurtdamage;

	public int missile_penetrationVal;

	public int missile_duo_hurt;

	public int missile_duo_pen;

	public List<AIController> curAIList;

	public AIController missileCurAi;

	public List<missilemove> curMissileAimlist = new List<missilemove>();

	public Effectobj lowhpsmoke;

	public Effectobj explosionobj;

	public Transform effectpoint;

	public float diedtime;

	public FightInfo fightinfo;

	public int contikill;

	private int curconti;

	private float[] camculldistance = new float[32];

	private bool havemissileshot;

	private bool havemissileshotduo;

	public GameObject speedeffect;

	private Vector3 nearpos = Vector3.zero;

	private Vector3 farpos = new Vector3(0f, 0f, 4.5f);

	private bool isexplo;

	private bool isleftfire;

	private Effectobj tempeffect;

	private float playerspeed;

	public bool isaim;

	public Vector3 aimpos;

	private Vector3 targetDir;

	private float angle;

	private float distence;

	private float a;

	private float b;

	private float c;

	private float d;

	private float r;

	private bool iscrash_collision;

	private Vector3 crashpoint;

	private void Start()
	{
		target = PlaneMoveController.instance.transform;
		bodypoint = PlaneMoveController.instance.bodypoint;
		plane_body.localPosition = bodypoint.localPosition;
		plane_body.localRotation = bodypoint.localRotation;
		if (UnityVersionUtil.IsActive(speedsmoke))
		{
			UnityVersionUtil.SetActiveRecursive(speedsmoke, state: false);
		}
		contikill = 0;
		curconti = 0;
	}

	public void set_speedeffect(GameObject spobj)
	{
		speedeffect = spobj;
		speedeffect.transform.parent = mainCam.transform;
		speedeffect.transform.localPosition = Vector3.zero;
		speedeffect.transform.localRotation = Quaternion.Euler(Vector3.zero);
	}

	public void set_speedpos()
	{
		speedeffect.transform.localPosition = Vector3.zero;
		speedeffect.transform.localRotation = Quaternion.Euler(Vector3.zero);
	}

	public void init_plane()
	{
		camculldistance[11] = 3000f;
		camculldistance[11] = 4000f;
		camculldistance[13] = 3000f;
		camculldistance[14] = 3000f;
		camculldistance[15] = 3000f;
		camculldistance[16] = 5000f;
		camculldistance[17] = 3000f;
		camculldistance[18] = 3000f;
		mainCam.layerCullDistances = camculldistance;
		m_Transform = base.transform;
		if (instance == null)
		{
			instance = this;
		}
		initObj();
		isdied = false;
		explosionobj = null;
		lowhpsmoke = null;
		iscrash_collision = false;
		isexplo = false;
		AIPool.instance.initinfo(fightdistance, plane_body);
		minimapcontroller.instance.initinfo(plane_body);
		init_player(GlobalInf.CurPlayerAtt.curweapon, GlobalInf.CurPlayerAtt.curheal);
	}

	public void init_player(player_weapon curweapon, heal_att curheal)
	{
		PlayerHealth.set_heal(curheal);
		if (GlobalInf.gamefirst)
		{
			bullet_hurtdamage = 40;
			bullet_penetrationVal = 20;
			missile_hurtdamage = 620;
			missile_penetrationVal = 20;
			missile_duo_hurt = 0;
			missile_duo_pen = 0;
		}
		else
		{
			bullet_hurtdamage = curweapon.machgun;
			bullet_penetrationVal = curweapon.machgun_pen;
			missile_hurtdamage = curweapon.missile;
			missile_penetrationVal = curweapon.missile_pen;
			missile_duo_hurt = curweapon.missile_duo;
			missile_duo_pen = curweapon.missile_duo_pen;
		}
		UIController.instance.weaponUIcon.initinfo(curweapon);
	}

	public void Reset_posrot()
	{
		PlaneMoveController.instance.reset_pos();
		plane_body.localPosition = bodypoint.localPosition;
		plane_body.localRotation = bodypoint.localRotation;
		isdied = false;
		if (lowhpsmoke != null)
		{
			EffectPool.instance.RecycleEffect(EFFECTTYPE.lowhpsmoke, lowhpsmoke);
		}
		if (explosionobj != null)
		{
			EffectPool.instance.RecycleEffect(EFFECTTYPE.diedexplosion, explosionobj);
		}
		explosionobj = null;
		lowhpsmoke = null;
		iscrash_collision = false;
		isexplo = false;
		cam_move.reset();
		PlayerHealth.resetheal();
		UIController.instance.change_playerHP(PlayerHealth.CurrentHP, PlayerHealth.MaxHP, is_bullet: false);
		UnityVersionUtil.SetActiveRecursive(plane_body.gameObject, state: true);
		UIController.instance.shakeui.stopshake();
	}

	public planefightinfo GetPlayerFightinfo()
	{
		planefightinfo planefightinfo = new planefightinfo();
		planefightinfo.planeindex = -1;
		planefightinfo.selfinfo = fightinfo;
		return planefightinfo;
	}

	public void change_fightinfo(AI_TYPE diedtype)
	{
		switch (diedtype)
		{
			case AI_TYPE.aiplane:
				fightinfo.killnum_plane++;
				curconti++;
				break;
			case AI_TYPE.aiship:
				fightinfo.killnum_ship++;
				break;
			case AI_TYPE.building:
				fightinfo.killnum_build++;
				break;
			case AI_TYPE.aibunker:
				fightinfo.killnum_build++;
				break;
			case AI_TYPE.aihgtw:
				fightinfo.killnum_build++;
				break;
			case AI_TYPE.aiboss:
				fightinfo.killnum_build++;
				break;
			case AI_TYPE.smallbuild:
				fightinfo.killnum_build++;
				break;
		}
	}

	public void getdamage(int hurt, int pene, int parent, bool isbullet)
	{
		if (isdied || GlobalInf.gameover)
		{
			return;
		}
		if (PlayerHealth.getDamage(hurt, pene))
		{
			fightinfo.diednum++;
			AIPool.instance.check_fightinfo(AI_TYPE.aiplane, parent, -1);
			if (GlobalInf.gamemode == TASKMODE.level && !GlobalInf.gamefirst)
			{
				GameUIController.instance.enable_reliveui();
			}
			if (!iscrash_collision)
			{
				cam_move.isdied = true;
				set_speedpos();
			}
			isdied = true;
			diedtime = 0f;
			if (curconti > contikill)
			{
				contikill = curconti;
			}
			curconti = 0;
			if (explosionobj == null)
			{
				explosionobj = EffectPool.instance.GetEffectObj(EFFECTTYPE.diedexplosion);
				if (explosionobj != null)
				{
					explosionobj.transform.parent = effectpoint;
					if (parent == -2)
					{
						explosionobj.transform.position = crashpoint;
					}
					else
					{
						explosionobj.transform.localPosition = Vector3.zero;
					}
					if (!UnityVersionUtil.IsActive(explosionobj.gameObject))
					{
						UnityVersionUtil.SetActiveRecursive(explosionobj.gameObject, state: true);
					}
				}
			}
			MonoInstance<AudioController>.instance.stop(AudioType.Gun);
			MonoInstance<AudioController>.instance.play(AudioType.playerExplosion, 0f);
		}
		if (isbullet)
		{
			MonoInstance<AudioController>.instance.play(AudioType.BulletHit, 0f);
		}
		else
		{
			MonoInstance<AudioController>.instance.play(AudioType.MissileHit, 0f);
		}
		UIController.instance.change_playerHP(PlayerHealth.CurrentHP, PlayerHealth.MaxHP, isbullet);
		if (!PlayerHealth.check_lowhp() || !(lowhpsmoke == null))
		{
			return;
		}
		lowhpsmoke = EffectPool.instance.GetEffectObj(EFFECTTYPE.lowhpsmoke);
		if (lowhpsmoke != null)
		{
			lowhpsmoke.transform.parent = effectpoint;
			lowhpsmoke.transform.localPosition = Vector3.zero;
			if (!UnityVersionUtil.IsActive(lowhpsmoke.gameObject))
			{
				UnityVersionUtil.SetActiveRecursive(lowhpsmoke.gameObject, state: true);
			}
		}
	}

	public void diedfun()
	{
		diedtime += Time.deltaTime;
		if (diedtime > 4f)
		{
			diedtime = 0f;
			if (lowhpsmoke != null)
			{
				EffectPool.instance.RecycleEffect(EFFECTTYPE.lowhpsmoke, lowhpsmoke);
			}
			if (explosionobj != null)
			{
				EffectPool.instance.RecycleEffect(EFFECTTYPE.diedexplosion, explosionobj);
			}
			lowhpsmoke = null;
			explosionobj = null;
			UnityVersionUtil.SetActiveRecursive(plane_body.gameObject, state: false);
		}
	}

	public void diedmove()
	{
		if (iscrash_collision)
		{
			cam_move.diedmove();
			return;
		}
		plane_body.transform.Translate(0f, 0f, Time.deltaTime * PlaneMoveController.instance.speed);
		plane_body.rotation = Quaternion.Lerp(plane_body.rotation, Quaternion.Euler(85f, 0f, 0f), Time.deltaTime * 0.2f);
		if (diedtime > 3f && !isexplo)
		{
			isexplo = true;
			if (explosionobj != null)
			{
				UnityVersionUtil.SetActiveRecursive(explosionobj.gameObject, state: false);
				UnityVersionUtil.SetActiveRecursive(explosionobj.gameObject, state: true);
			}
		}
	}

	public float GetHPpercent()
	{
		return (float)PlayerHealth.CurrentHP / (float)PlayerHealth.MaxHP;
	}

	private void OnDestroy()
	{
		if (instance != null)
		{
			instance = null;
		}
	}

	public void initObj()
	{
		UnityVersionUtil.SetActiveRecursive(left_fire.gameObject, state: false);
		UnityVersionUtil.SetActiveRecursive(right_fire.gameObject, state: false);
	}

	private void LateUpdate()
	{
		if (isdied)
		{
			diedfun();
			diedmove();
		}
		else
		{
			if (GlobalInf.gameover)
			{
				return;
			}
			followmove();
			rotate_empennage_android();
			rotate_flank_android();
			if (!groundtrigger.triggered)
			{
				Vector3 vector = m_Transform.InverseTransformPoint(mainCam.transform.position);
				if (vector.z < 0f)
				{
					UIController.instance.SetPlayerAim(mainCam.WorldToScreenPoint(plane_body.position + plane_body.forward * 180f), istrue: true);
				}
				else
				{
					UIController.instance.SetPlayerAim(Vector3.zero, istrue: false);
				}
				if (machinegunFlag || UnityEngine.Input.GetKey(KeyCode.J))
				{
					if (!UnityVersionUtil.IsActive(left_fire.gameObject))
					{
						UnityVersionUtil.SetActiveRecursive(left_fire.gameObject, state: true);
						UnityVersionUtil.SetActiveRecursive(right_fire.gameObject, state: true);
					}
					machineBullet();
				}
				else
				{
					MonoInstance<AudioController>.instance.stop(AudioType.Gun);
					if (UnityVersionUtil.IsActive(left_fire.gameObject))
					{
						UnityVersionUtil.SetActiveRecursive(left_fire.gameObject, state: false);
						UnityVersionUtil.SetActiveRecursive(right_fire.gameObject, state: false);
					}
				}
				if (guidedmissileFlag)
				{
					missileShotduo();
				}
				else
				{
					havemissileshotduo = false;
				}
				if (singlemissileFlag)
				{
					singleMissileShot();
				}
				else
				{
					havemissileshot = false;
				}
				if (accflag || UnityEngine.Input.GetKey(KeyCode.Z) || PlaneMoveController.instance.speed > 120f)
				{
					Vector3 position = m_Transform.position;
					if (position.y > 500f && GlobalInf.ishavespeedsmoke)
					{
						if (!UnityVersionUtil.IsActive(speedsmoke))
						{
							UnityVersionUtil.SetActiveRecursive(speedsmoke, state: true);
						}
					}
					else if (UnityVersionUtil.IsActive(speedsmoke))
					{
						UnityVersionUtil.SetActiveRecursive(speedsmoke, state: false);
					}
					if (GlobalInf.CurrentQuality > (Quality)101)
					{
						Transform transform = left_jet;
						Vector3 localScale = left_jet.localScale;
						transform.localScale = new Vector3(1f, 1f, Mathf.Lerp(localScale.z, 1.3f, Time.deltaTime));
						if (right_jet != null)
						{
							Transform transform2 = right_jet;
							Vector3 localScale2 = left_jet.localScale;
							transform2.localScale = new Vector3(1f, 1f, Mathf.Lerp(localScale2.z, 1.3f, Time.deltaTime));
						}
					}
				}
				else
				{
					if (UnityVersionUtil.IsActive(speedsmoke))
					{
						UnityVersionUtil.SetActiveRecursive(speedsmoke, state: false);
					}
					if (GlobalInf.CurrentQuality > (Quality)101)
					{
						Transform transform3 = left_jet;
						Vector3 localScale3 = left_jet.localScale;
						transform3.localScale = new Vector3(1f, 1f, Mathf.Lerp(localScale3.z, 1f, Time.deltaTime));
						if (right_jet != null)
						{
							Transform transform4 = right_jet;
							Vector3 localScale4 = left_jet.localScale;
							transform4.localScale = new Vector3(1f, 1f, Mathf.Lerp(localScale4.z, 1f, Time.deltaTime));
						}
					}
				}
			}
			if (accflag || UnityEngine.Input.GetKey(KeyCode.Z))
			{
				if (speedeffect != null)
				{
					Vector3 position2 = m_Transform.position;
					if (position2.y > 200f && PlaneMoveController.instance.speed > 140f)
					{
						speedeffect.transform.localPosition = Vector3.Lerp(speedeffect.transform.localPosition, farpos, Time.deltaTime * 1f);
					}
					else
					{
						speedeffect.transform.localPosition = Vector3.Lerp(speedeffect.transform.localPosition, nearpos, Time.deltaTime * 1f);
					}
				}
				if (PlaneMoveController.instance.speed > 140f)
				{
					MonoInstance<AudioController>.instance.setpitch_acc();
				}
				mainCam.fieldOfView = Mathf.Lerp(mainCam.fieldOfView, 75f, 0.4f * Time.deltaTime);
				nearCam.fieldOfView = mainCam.fieldOfView;
			}
			else
			{
				if (speedeffect != null)
				{
					speedeffect.transform.localPosition = Vector3.Lerp(speedeffect.transform.localPosition, nearpos, Time.deltaTime * 1f);
				}
				mainCam.fieldOfView = Mathf.Lerp(mainCam.fieldOfView, 60f, 0.2f * Time.deltaTime);
				nearCam.fieldOfView = mainCam.fieldOfView;
				if (PlaneMoveController.instance.speed > 140f)
				{
					MonoInstance<AudioController>.instance.setpitch_dec();
				}
			}
		}
	}

	public void machineBullet()
	{
		if (isleftfire)
		{
			curbullet = bulletpool.instance.GetplayerBullet();
			if (!(curbullet == null))
			{
				MonoInstance<AudioController>.instance.play(AudioType.Gun, 0f);
				curbullet.transform.position = left_fire.position + left_fire.forward * 15f;
				curbullet.transform.rotation = left_fire.rotation;
				curbullet.targetAI = curAI;
				curbullet.isplayerbullet = true;
				curbullet.movespeed = machinespeed;
				curbullet.shot(bullet_hurtdamage, bullet_penetrationVal, -1);
				UIController.instance.showbulletnum(1);
				isleftfire = false;
			}
		}
		else
		{
			curbullet = bulletpool.instance.GetplayerBullet();
			if (!(curbullet == null))
			{
				MonoInstance<AudioController>.instance.play(AudioType.Gun, 0f);
				curbullet.transform.position = right_fire.position + right_fire.forward * 15f;
				curbullet.transform.rotation = right_fire.rotation;
				curbullet.targetAI = curAI;
				curbullet.isplayerbullet = true;
				curbullet.movespeed = machinespeed;
				curbullet.shot(bullet_hurtdamage, bullet_penetrationVal, -1);
				UIController.instance.showbulletnum(1);
				isleftfire = true;
			}
		}
	}

	public void missileShotduo()
	{
		if (havemissileshotduo)
		{
			return;
		}
		havemissileshotduo = true;
		if (curAIList.Count > 0)
		{
			for (int i = 0; i < curAIList.Count; i++)
			{
				Vector3 vector = m_Transform.InverseTransformPoint(curAIList[i].m_transform.position);
				if (vector.x <= 0f)
				{
					if (UIController.instance.weaponUIcon.cur_missile > 0)
					{
						curmissile = missilepool.instance.GetMissileduo();
					}
					else
					{
						curmissile = null;
					}
					if (curmissile == null)
					{
						break;
					}
					MonoInstance<AudioController>.instance.play(AudioType.Missile, 0f);
					curmissile.transform.position = left_missile.position;
					curmissile.transform.rotation = left_missile.rotation;
					curmissile.targetAI = curAIList[i];
					curmissile.isplayerbullet = true;
					curmissile.movespeed = guidemissilespeed;
					curmissile.shot(missile_duo_hurt, missile_duo_pen, -1, PlaneMoveController.instance.speed);
					UIController.instance.showbulletnum(2);
				}
				else
				{
					if (UIController.instance.weaponUIcon.cur_missile > 0)
					{
						curmissile = missilepool.instance.GetMissileduo();
					}
					else
					{
						curmissile = null;
					}
					if (curmissile == null)
					{
						break;
					}
					MonoInstance<AudioController>.instance.play(AudioType.Missile, 0f);
					curmissile.transform.position = right_missile.position;
					curmissile.transform.rotation = right_missile.rotation;
					curmissile.targetAI = curAIList[i];
					curmissile.isplayerbullet = true;
					curmissile.movespeed = guidemissilespeed;
					curmissile.shot(missile_duo_hurt, missile_duo_pen, -1, PlaneMoveController.instance.speed);
					UIController.instance.showbulletnum(2);
				}
			}
		}
		else if (isleftfire)
		{
			if (UIController.instance.weaponUIcon.cur_missile > 0)
			{
				curmissile = missilepool.instance.GetMissileduo();
			}
			else
			{
				curmissile = null;
			}
			if (!(curmissile == null))
			{
				MonoInstance<AudioController>.instance.play(AudioType.Missile, 0f);
				curmissile.transform.position = left_missile.position;
				curmissile.transform.rotation = left_missile.rotation;
				curmissile.targetAI = null;
				curmissile.isplayerbullet = true;
				curmissile.movespeed = guidemissilespeed;
				curmissile.shot(missile_duo_hurt, missile_duo_pen, -1, PlaneMoveController.instance.speed);
				UIController.instance.showbulletnum(2);
				isleftfire = false;
			}
		}
		else
		{
			if (UIController.instance.weaponUIcon.cur_missile > 0)
			{
				curmissile = missilepool.instance.GetMissileduo();
			}
			else
			{
				curmissile = null;
			}
			if (!(curmissile == null))
			{
				MonoInstance<AudioController>.instance.play(AudioType.Missile, 0f);
				curmissile.transform.position = right_missile.position;
				curmissile.transform.rotation = right_missile.rotation;
				curmissile.targetAI = null;
				curmissile.isplayerbullet = true;
				curmissile.movespeed = guidemissilespeed;
				curmissile.shot(missile_duo_hurt, missile_duo_pen, -1, PlaneMoveController.instance.speed);
				UIController.instance.showbulletnum(2);
				isleftfire = true;
			}
		}
	}

	public void singleMissileShot()
	{
		if (havemissileshot)
		{
			return;
		}
		havemissileshot = true;
		curmissile = missilepool.instance.GetMissile();
		if (curmissile != null)
		{
			MonoInstance<AudioController>.instance.play(AudioType.Missile, 0f);
			if (isleftfire)
			{
				curmissile.transform.position = left_missile.position;
				curmissile.transform.rotation = left_missile.rotation;
				curmissile.targetAI = missileCurAi;
				curmissile.isplayerbullet = true;
				curmissile.movespeed = guidemissilespeed;
				curmissile.shot(missile_hurtdamage, missile_penetrationVal, -1, PlaneMoveController.instance.speed);
				isleftfire = false;
			}
			else
			{
				curmissile.transform.position = right_missile.position;
				curmissile.transform.rotation = right_missile.rotation;
				curmissile.targetAI = missileCurAi;
				curmissile.isplayerbullet = true;
				curmissile.movespeed = guidemissilespeed;
				curmissile.shot(missile_hurtdamage, missile_penetrationVal, -1, PlaneMoveController.instance.speed);
				isleftfire = true;
			}
			UIController.instance.showbulletnum(3);
		}
	}

	public void youdaodanfire()
	{
		tempeffect = EffectPool.instance.GetEffectObj(EFFECTTYPE.youdaodan);
		if (tempeffect != null)
		{
			tempeffect.transform.parent = youdaodan_point;
			tempeffect.transform.localPosition = Vector3.zero;
			tempeffect.transform.localRotation = Quaternion.identity;
			tempeffect.showeffect();
			UIController.instance.showbulletnum(4);
		}
		for (int i = 0; i < curMissileAimlist.Count; i++)
		{
			curMissileAimlist[i].targetTra = null;
			curMissileAimlist[i].ishaveaim = false;
		}
		curMissileAimlist.Clear();
	}

	public void addaimMissile(missilemove mis)
	{
		curMissileAimlist.Add(mis);
	}

	public void decaimMissile(missilemove mis)
	{
		curMissileAimlist.RemoveAt(curMissileAimlist.IndexOf(mis));
		mis.ishaveaim = false;
		if (curMissileAimlist.Count == 0)
		{
			UIController.instance.planeisaim(istrue: false);
		}
	}

	private float lastFixedTime = 0;
	public void followmove()
	{
		if (!(target == null) && lastFixedTime != Time.fixedTime)
		{
			lastFixedTime = Time.fixedTime;
			start_ro = m_Transform.rotation;
			end_to = target.rotation;
			curpos = Vector3.Lerp(m_Transform.position, target.position, Time.deltaTime * posDamping);
			m_Transform.position = curpos;
			m_Transform.rotation = Quaternion.Lerp(start_ro, end_to, Time.deltaTime * rotationDamping);
			plane_body.localPosition = Vector3.Lerp(plane_body.localPosition, bodypoint.localPosition, Time.deltaTime * posDamping);
			plane_body.localRotation = Quaternion.Lerp(plane_body.localRotation, bodypoint.localRotation, Time.deltaTime * rotationDamping);
		}
	}

	public void rotate_empennage()
	{
		if (!(leftempennage == null))
		{
			if (Mathf.Abs(UnityEngine.Input.GetAxis("Vertical")) >= 0.5f)
			{
				Vector3 localEulerAngles = leftempennage.localEulerAngles;
				empennage_curangle = Mathf.LerpAngle(localEulerAngles.x, (0f - UnityEngine.Input.GetAxis("Vertical")) * empennage_angle, Time.deltaTime * 4f);
			}
			else
			{
				Vector3 localEulerAngles2 = leftempennage.localEulerAngles;
				empennage_curangle = Mathf.LerpAngle(localEulerAngles2.x, 0f, Time.deltaTime * 2f);
			}
			leftempennage.localRotation = Quaternion.Euler(empennage_curangle, 0f, 0f);
			rightempennage.localRotation = Quaternion.Euler(empennage_curangle, 0f, 0f);
		}
	}

	public void rotate_empennage_android()
	{
		if (leftempennage == null)
		{
			return;
		}
		if (GlobalInf.PlaneCtrlType == PLANECTRLTYPE.BUTTON)
		{
			if (Mathf.Abs(Joystick.joystickAxis.y) >= 0.1f)
			{
				Vector3 localEulerAngles = leftempennage.localEulerAngles;
				empennage_curangle = Mathf.LerpAngle(localEulerAngles.x, (0f - Joystick.joystickAxis.y) * empennage_angle, Time.deltaTime * 4f);
			}
			else
			{
				Vector3 localEulerAngles2 = leftempennage.localEulerAngles;
				empennage_curangle = Mathf.LerpAngle(localEulerAngles2.x, 0f, Time.deltaTime * 2f);
			}
		}
		else if (Mathf.Abs(Joystick.gravityAxis.x) >= 0.1f)
		{
			Vector3 localEulerAngles3 = leftempennage.localEulerAngles;
			empennage_curangle = Mathf.LerpAngle(localEulerAngles3.x, (0f - Joystick.gravityAxis.x) * empennage_angle, Time.deltaTime * 4f);
		}
		else
		{
			Vector3 localEulerAngles4 = leftempennage.localEulerAngles;
			empennage_curangle = Mathf.LerpAngle(localEulerAngles4.x, 0f, Time.deltaTime * 2f);
		}
		leftempennage.localRotation = Quaternion.Euler(empennage_curangle, 0f, 0f);
		rightempennage.localRotation = Quaternion.Euler(empennage_curangle, 0f, 0f);
	}

	public void rotate_flank()
	{
		if (leftblank == null)
		{
			return;
		}
		if (Mathf.Abs(UnityEngine.Input.GetAxis("Horizontal")) >= 0.5f)
		{
			Vector3 localEulerAngles = leftblank.localEulerAngles;
			flank_curangle_left = Mathf.LerpAngle(localEulerAngles.x, (0f - UnityEngine.Input.GetAxis("Horizontal")) * flank_angle, Time.deltaTime * 4f);
			if (rightblank != null)
			{
				Vector3 localEulerAngles2 = rightblank.localEulerAngles;
				flank_curangle_right = Mathf.LerpAngle(localEulerAngles2.x, UnityEngine.Input.GetAxis("Horizontal") * flank_angle, Time.deltaTime * 4f);
			}
		}
		else
		{
			Vector3 localEulerAngles3 = leftblank.localEulerAngles;
			flank_curangle_left = Mathf.LerpAngle(localEulerAngles3.x, 0f, Time.deltaTime * 2f);
			if (rightblank != null)
			{
				Vector3 localEulerAngles4 = rightblank.localEulerAngles;
				flank_curangle_right = Mathf.LerpAngle(localEulerAngles4.x, 0f, Time.deltaTime * 2f);
			}
		}
		Transform transform = leftblank;
		float x = flank_curangle_left;
		Vector3 localEulerAngles5 = leftblank.localEulerAngles;
		float y = localEulerAngles5.y;
		Vector3 localEulerAngles6 = leftblank.localEulerAngles;
		transform.localRotation = Quaternion.Euler(x, y, localEulerAngles6.z);
		if (rightblank != null)
		{
			Transform transform2 = rightblank;
			float x2 = flank_curangle_right;
			Vector3 localEulerAngles7 = rightblank.localEulerAngles;
			float y2 = localEulerAngles7.y;
			Vector3 localEulerAngles8 = rightblank.localEulerAngles;
			transform2.localRotation = Quaternion.Euler(x2, y2, localEulerAngles8.z);
		}
	}

	public void rotate_flank_android()
	{
		if (leftblank == null)
		{
			return;
		}
		if (GlobalInf.PlaneCtrlType == PLANECTRLTYPE.BUTTON)
		{
			if (Mathf.Abs(Joystick.joystickAxis.x) >= 0.1f)
			{
				Vector3 localEulerAngles = leftblank.localEulerAngles;
				flank_curangle_left = Mathf.LerpAngle(localEulerAngles.x, (0f - Joystick.joystickAxis.x) * flank_angle, Time.deltaTime * 4f);
				if (rightblank != null)
				{
					Vector3 localEulerAngles2 = rightblank.localEulerAngles;
					flank_curangle_right = Mathf.LerpAngle(localEulerAngles2.x, Joystick.joystickAxis.x * flank_angle, Time.deltaTime * 4f);
				}
			}
			else
			{
				Vector3 localEulerAngles3 = leftblank.localEulerAngles;
				flank_curangle_left = Mathf.LerpAngle(localEulerAngles3.x, 0f, Time.deltaTime * 2f);
				if (rightblank != null)
				{
					Vector3 localEulerAngles4 = rightblank.localEulerAngles;
					flank_curangle_right = Mathf.LerpAngle(localEulerAngles4.x, 0f, Time.deltaTime * 2f);
				}
			}
		}
		else if (Mathf.Abs(Joystick.gravityAxis.y) >= 0.1f)
		{
			Vector3 localEulerAngles5 = leftblank.localEulerAngles;
			flank_curangle_left = Mathf.LerpAngle(localEulerAngles5.x, (0f - Joystick.gravityAxis.y) * flank_angle, Time.deltaTime * 4f);
			if (rightblank != null)
			{
				Vector3 localEulerAngles6 = rightblank.localEulerAngles;
				flank_curangle_right = Mathf.LerpAngle(localEulerAngles6.x, Joystick.gravityAxis.y * flank_angle, Time.deltaTime * 4f);
			}
		}
		else
		{
			Vector3 localEulerAngles7 = leftblank.localEulerAngles;
			flank_curangle_left = Mathf.LerpAngle(localEulerAngles7.x, 0f, Time.deltaTime * 2f);
			if (rightblank != null)
			{
				Vector3 localEulerAngles8 = rightblank.localEulerAngles;
				flank_curangle_right = Mathf.LerpAngle(localEulerAngles8.x, 0f, Time.deltaTime * 2f);
			}
		}
		Transform transform = leftblank;
		float x = flank_curangle_left;
		Vector3 localEulerAngles9 = leftblank.localEulerAngles;
		float y = localEulerAngles9.y;
		Vector3 localEulerAngles10 = leftblank.localEulerAngles;
		transform.localRotation = Quaternion.Euler(x, y, localEulerAngles10.z);
		if (rightblank != null)
		{
			Transform transform2 = rightblank;
			float x2 = flank_curangle_right;
			Vector3 localEulerAngles11 = rightblank.localEulerAngles;
			float y2 = localEulerAngles11.y;
			Vector3 localEulerAngles12 = rightblank.localEulerAngles;
			transform2.localRotation = Quaternion.Euler(x2, y2, localEulerAngles12.z);
		}
	}

	public Vector3 playerAim(Vector3 bulletpos, float bulletspeed)
	{
		playerspeed = PlaneMoveController.instance.speed;
		aimpos = Vector3.zero;
		if (playerspeed < 1f)
		{
			isaim = true;
			aimpos = plane_body.position;
		}
		else
		{
			targetDir = bulletpos - plane_body.position;
			angle = Vector3.Angle(targetDir, plane_body.forward);
			distence = targetDir.magnitude;
			a = MyMath.GetPom(bulletspeed / playerspeed, 2f);
			b = MyMath.GetRad(distence, angle);
			c = distence * distence;
			d = MyMath.GetDelta(a, b, c);
			isaim = (d >= 0f && !float.IsNaN(d) && !float.IsInfinity(d));
			if (isaim)
			{
				r = MyMath.GetSqrtOfMath(a, b, d);
				if (r < 0f)
				{
					isaim = false;
				}
				aimpos = plane_body.position + plane_body.forward * r;
			}
		}
		if (aimpos == Vector3.zero || !isaim)
		{
			aimpos = plane_body.position;
		}
		return aimpos;
	}

	public void crashcollision()
	{

		crashpoint = m_Transform.position - m_Transform.forward * 10f;
		iscrash_collision = true;
		getdamage(PlayerHealth.MaxHP, PlayerHealth.ArmorVal, -2, isbullet: false);
	}

	public Vector3 GetForwardpos()
	{
		Vector3 vector = m_Transform.forward;
		vector.y = 0f;
		vector = vector.normalized;
		return m_Transform.position + vector * 1000f - m_Transform.right * 100f + Vector3.up * 400f;
	}
}
